package docs.cvs.service;

import docs.cvs.dao.UserDao;
import docs.cvs.dao.impl.UserDaoImpl;
import docs.cvs.pojo.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户业务类，实现对user功能的业务管理
 */
@Service("UserServiceImpl")
public class UserServiceImpl {
    private static final Logger logger = Logger.getLogger(UserServiceImpl.class);
    
    public UserServiceImpl(UserDao dao) {
        this.dao = dao;
    }
    
//    @Resource(name="userDao")
//    @Autowired
//    @Resource(name = "userDao")
    @Resource(type = UserDaoImpl.class)
    private UserDao dao;
    
    public UserServiceImpl(UserDaoImpl userDao) {
        this.dao =userDao;
    }
    
    public void setDao(UserDao dao) {
        this.dao = dao;
    }
    
    public UserServiceImpl() {
    }
    
    public boolean save(User user) {
        logger.info("添加用户"+user.getRealName());
        SqlSession sqlSession = null;
        boolean flag = false;
        //调用保存方法
        dao.save(user);
        return true;
    }
    
    public User getUser(User user) {
        return dao.getUser(user);
    }
    
    
}
